package com.teamcenter.rac.massupdate.utils;

import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentManager;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.AdapterUtil;
import java.util.Collection;
import java.util.Iterator;
import org.eclipse.ui.views.properties.IPropertySource;

public class SourceHelper
{
  public static TCComponent getAssociatedComponent(IPropertySource paramIPropertySource, TCSession paramTCSession)
  {
    String str = (String)paramIPropertySource.getPropertyValue("UID");
    if ((str != null) && (!str.trim().isEmpty()))
    {
      TCComponentManager localTCComponentManager = paramTCSession.getComponentManager();
      return localTCComponentManager.getCachedComponent(str);
    }
    return null;
  }
  
  public static TCComponent[] convertToTCComponents(Collection<TCComponent> paramCollection)
  {
    Iterator<TCComponent> localIterator = paramCollection.iterator();
    TCComponent[] arrayOfTCComponent = new TCComponent[paramCollection.size()];
    int i = 0;
    while (localIterator.hasNext())
    {
      TCComponent localTCComponent = (TCComponent)AdapterUtil.getAdapter(localIterator.next(), TCComponent.class);
      arrayOfTCComponent[(i++)] = localTCComponent;
    }
    return arrayOfTCComponent;
  }
}

